-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Implement helper method to get char* buffer from Python objects #25895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement helper method to get char* buffer from Python objects #25895
Conversation
…ze in Python3.7 case; added docstring to get_string_data func
…et_string_data docstring
Note for reviewers: errors in CI seem to be caused by #25875 |
Codecov Report
@@ Coverage Diff @@
## master #25895 +/- ##
=======================================
Coverage 91.47% 91.47%
=======================================
Files 175 175
Lines 52863 52863
=======================================
Hits 48357 48357
Misses 4506 4506
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #25895 +/- ##
==========================================
+ Coverage 91.53% 91.77% +0.23%
==========================================
Files 175 175
Lines 52808 52606 -202
==========================================
- Hits 48338 48277 -61
+ Misses 4470 4329 -141
Continue to review full report at Codecov.
|
0b6902b
to
1db613e
Compare
Fun fact - it speeds up iso8601 parsing noticeably:
|
lgtm. @jbrockmendel ? |
lgtm. @jbrockmendel merge when ready. |
Thanks @vnlitvin |
…as-dev#25895) * removed extra layer; using get_string_data now * fix problem with const char* value, that return PyUnicode_AsUTF8AndSize in Python3.7 case; added docstring to get_string_data func * fix code style * replaced get_c_string to get_string_data, added 'note' paragraph in get_string_data docstring * Re-instate raising TypeError when trying to get string data of non-string object * test case for overflow in parse_iso_8601_datetime * change get_string_data signature to more pythonic * Added test for parsing leading spaces * Rework get_string_data to cleaner get_c_string_buf_and_size * Fix Python 3.7 compilation * added comment for test; changed name variable: s -> py_string
test_parsers_iso8601_leading_space
git diff upstream/master -u -- "*.py" | flake8 --diff
This is a follow-up PR for #25754 which adds a utility method for getting internal
char *
buffer fromunicode
orbytes
Python object and switch at least some of usages to it.Its advantages over what is built-in in Cython is saving at least one extra memory allocation (Cython internally calls Python C API that creates a new
char *
copy which is not needed for mostunicode
objects which are internally stored inutf8
encoding), and it also obtains the length in one call.cc @jbrockmendel